/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.xtd.model.admin;

import java.io.Serializable;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 *
 * @author Lu Yuanbin
 */
@Entity
@Table(name = "xtdrole")
@NamedQueries({
    @NamedQuery(name = "UserGroup.findAll", query = "SELECT u FROM UserGroup u")})
public class UserGroup implements Serializable {

    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected UserGroupPK userGroupPK;
    @JoinColumn(name = "username", referencedColumnName = "username",insertable=false,updatable=false)
    @ManyToOne
    private Xtduser xtduser;
    @JoinColumn(name = "groupname", referencedColumnName = "name",insertable=false,updatable=false)
    @ManyToOne
    private Xtdgroup xtdgroup;

    public UserGroup() {
    }

    public UserGroup(UserGroupPK userGroupPK) {
        this.userGroupPK = userGroupPK;
    }

    public UserGroup(String username, String groupname) {
        this.userGroupPK = new UserGroupPK(username, groupname);
    }

    public UserGroupPK getUserGroupPK() {
        return userGroupPK;
    }

    public void setUserGroupPK(UserGroupPK userGroupPK) {
        this.userGroupPK = userGroupPK;
    }

   

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (userGroupPK != null ? userGroupPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof UserGroup)) {
            return false;
        }
        UserGroup other = (UserGroup) object;
        if ((this.userGroupPK == null && other.userGroupPK != null) || (this.userGroupPK != null && !this.userGroupPK.equals(other.userGroupPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.xtd.model.admin.UserGroup[userGroupPK=" + userGroupPK + "]";
    }

    /**
     * @return the xtduser
     */
    public Xtduser getXtduser() {
        return xtduser;
    }

    /**
     * @param xtduser the xtduser to set
     */
    public void setXtduser(Xtduser xtduser) {
        this.xtduser = xtduser;
    }

    /**
     * @return the xtdgroup
     */
    public Xtdgroup getXtdgroup() {
        return xtdgroup;
    }

    /**
     * @param xtdgroup the xtdgroup to set
     */
    public void setXtdgroup(Xtdgroup xtdgroup) {
        this.xtdgroup = xtdgroup;
    }
}
